import { defineEventHandler } from "h3";
import requireAuth from "../../../middleware/secure";
import { UserService } from "../../../services/userService";

export default defineEventHandler(async (event) => {
  const user = await requireAuth(event);

  const subscription = await UserService.getUserSubscription(user.id);
  const isProUser = await UserService.isProUser(user.id);

  return {
    subscription,
    isPro: isProUser,
    status: subscription?.status || "free",
  };
});